<% content_for :action_nav do %>
<!-- begin action nav -->
<div id="page-nav">
  <ul id="act-nav" class="clear">
    <li><%= link_to "Create new article", :action => "new" %></li>
  </ul>
</div>
<!-- /end action nav -->
<div id="filter" class="manual">
  <ul class="clear">
    <li><a href="#">&nbsp;</a></li>
  </ul>
  <% form_tag({:action => 'index'}, :method => 'get', :id => 'article-search') do -%>
  <ul id="attributes">
    <li><label for="search">Show articles:</label></li>
    <li>
      <select name="filter" id="filterlist">
        <%= options_for_select [
          ['in section',           'section'],
          ['tagged with',          'tags'],
          ['whose title contains', 'title'],
          ['whose body contains',  'body'],
          ['not published',        'draft']
        ] %>
      </select>
      <select name="section" id="sectionlist">
        <option value="0">&mdash;All Sections&mdash;</option>
        <%= options_from_collection_for_select @sections, :id, :name, params[:section].to_i %>
      </select>
    </li>
    <li><%= text_field_tag 'q', params[:q], :id => 'manualsearch', :style => 'display:none' %></li>
    <li><input type="button" id="searchsubmit" value="Go" style="display:none" /></li>
  </ul>
    <div><%= hidden_field_tag :published, 1 %></div>
  <% end -%>
</div>
<% end %>

<% if @articles.size > 0 -%>

<% content_tag :p, :class => 'total' do %>
  Total: <%= content_tag :strong, @articles.total_entries %> articles.
<% end %>

<!-- begin article list -->
<table id="article-list" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th scope="col" class="small-col">Status</th>
      <th scope="col">Article</th>
      <th scope="col">Comments</th>
      <th scope="col">Published</th>
      <th scope="col">&nbsp;</th>
    </tr>
  </thead>
  <tbody id="articles">
      <%= render :partial => 'article', :collection => @articles %>
  </tbody>
</table>
<!-- /end article list -->

<!-- begin pagination -->
<% if @articles.page_count > 1 -%>
  <%= will_paginate @articles, :id => 'pagination' %>
<% end -%>
<!-- /end pagination -->

<% else %>
  <div class="empty" style="margin-bottom:20px">
    <% unless params[:filter] %>
      You have no articles.  <%= link_to "Create one now &raquo;", :action => "new" %>
    <% else %>
      You don't seem to have any articles matching that criteria.
    <% end %>
  </div>
<% end %>

<% content_for :sidebar do %>
  <% if @comments.any? -%>
  <div class="sgroup">
    <h3>Comments awaiting your approval</h3>
    <ul class="slist">
    <% @comments.each do |article, count| -%>
      <li><%= link_to "<strong>(#{count})</strong> #{h(article.title)}", article_comments_path(article), :filter => :unapproved %></li>
    <% end -%>
    </ul>
  </div>
  <% end -%>
<% end %>
